package com.seari.custody.component;

import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.interceptor.KeyGenerator;
import org.springframework.stereotype.Component;

import java.lang.reflect.Method;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 缓存key值生成
 */
@Slf4j
@Component
public class MyKeyGenerator implements KeyGenerator {
    @Override
    public Object generate(Object target, Method method, Object... params) {
        String s = target.getClass().getName() + method.getName() +
                Stream.of(params).map(Object::toString).collect(Collectors.joining(","));
//        log.info("cache key: " + s);
        return s;
    }
}